using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Sublimation
{
    public class ScriptedEventUnlockPriest : ScriptedEvent
    {
        public ScriptedEventUnlockPriest(WorldProperties worldProperties)
            : base(worldProperties)
        {
        }

        protected const double SCRIPT_START_TIME_SECONDS = 180;
        
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            // 1:20 - unlock priests
            if (state == 0)
            {
                if (gameTime.TotalGameTime.Subtract(worldProperties.PauseTime).TotalSeconds >= SCRIPT_START_TIME_SECONDS) state = 1;

            }
            else if (state == 1)
            {
                // write the text warning of his approach
                worldProperties.DrawTextWarning("Light priests have entered the battle.", ScriptedEvent.DEFAULT_LONG_TEXT_MILLIS);
                state = 2;

            } else if(state == 2) {
                if (gameTime.TotalGameTime.Subtract(worldProperties.PauseTime).TotalSeconds >= SCRIPT_START_TIME_SECONDS + 2) state = 3;

            } else if(state == 3) {
                // show the appearing animation/effect
                worldProperties.PriestEnabled = true;
                state = 4;

            }
            else if (state == 4)
            {
                Game.Components.Remove(this);

            }
        }
    }
}